﻿using KL.Core.Common.MyOptions;
using Microsoft.Extensions.Options;
using MongoDB.Driver;

namespace KL.Standard.Mongo.Repositories
{
    public class KLMongoClient
    {
        public MongoClient Client { get; private set; }
        public  IMongoDatabase Database{ get; private set; }
        
        // public KLMongoClient(string connectionString,string dbName)
        // {
        //     Client = new MongoClient(connectionString);
        //     Database = Client.GetDatabase(dbName);
        // }

        public KLMongoClient(IOptions<MongoDBOptions> options)
        {
            var klMongoOptions = options.Value;
            Client = new MongoClient(klMongoOptions.CONNECTION_STR);
            Database = Client.GetDatabase(klMongoOptions.DBNAME);
        }
    }
}